package cn.jbolt.ec.order.handler;

import cn.jbolt.common.model.*;

/**
 * 平台充值
 */
public class TypeE {




    public int handle(int client_id,int amount){

        /*
        生成新订单
         */
        BecRetailerOrder becRetailerOrder = new BecRetailerOrder();
        BecMember member = new BecMember().dao().findById(client_id);
        becRetailerOrder.setAddress("充值")
                .setMobile(" "+member.getMobile())
                .setConsignee(" "+member.getNickname()).setStatus(5)
                .setType(5).setClientId(client_id).setRetailerId(0);

        long t =System.currentTimeMillis();

        String orderids = "j-"+t+'-'+client_id+"-0";
        becRetailerOrder.setOrderId(orderids).setOrderTime(t);
        becRetailerOrder.setAmountTotal((long)amount);
        becRetailerOrder.setAmountPaid((long)amount);
        becRetailerOrder.setCashAmount(amount);

        if(!becRetailerOrder.save()) return -1; // 订单生成失败





        return becRetailerOrder.getId();


    }

}
